package main

import (
	"strconv"
)

func compressString(S string) string {
	if len(S) == 0 {
		return ""
	}
	var res []byte
	num := 0
	var temp byte = S[0]
	for _, b := range []byte(S) {
		if b == temp {
			num++
		} else {
			res = append(res, temp)
			res = append(res, strconv.Itoa(num)...)
			num = 1
			temp = b
		}
	}
	if num > 0 {
		res = append(res, temp)
		res = append(res, strconv.Itoa(num)...)
	}
	if len(res) > len(S) {
		return S
	}
	return string(res)
}
